This example is actually the source for /usr/etc/fdform, the NeXT Floppy Disk Format utility. This formats a floppy disk at any specified density using the fd driver. Command line options are as described in the fdform man page.
This example illustrates how to do the following:
-- Inquire the fd driver as to the type of media present.
-- Give the driver new format parameters.
-- Generate commands, such as Recalibrate, Format Track, and Seek, and
send them to the Intel 82077 controller chip via the FDIOCREQ ioctl.
-- Read the disk, one track at a time, using the FDIOCRRW ioctl.
Refer to the man page for fd(4) for specific information on using the floppy disk driver.